import { createStore } from "vuex";

export default createStore({
  state: {
    /**
     * @param user 用户信息
     */
    user: JSON.parse(window.localStorage.getItem("user") ?? "{}"),
  },
  mutations: {
    setUser(state, payload) {
      state.user = JSON.parse(payload);
      window.localStorage.setItem("user", payload);
    },
  },
  actions: {},
  modules: {},
});
